package com.qf.openapi.web.master.inter;

import com.qf.openapi.web.master.ex.UserException;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class PlateformInterceptor implements HandlerInterceptor {
    /**
     *  拦截访问plateform界面
     * @param request
     * @param response
     * @param handler
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        String sessionValue = null;
        sessionValue =(String) session.getAttribute("get");
        if (sessionValue==null||!sessionValue.equals("login")){
            response.sendRedirect("/login.html");
        }else {
            return true;
        }
        return false;
    }
}
